/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class UserInfoDataAccess
    {
        public List<UserInfo_Entity> UserInfo_ListByPaging(int pageSize, int pageIndex,out int total)
        {
			total= 0;
            try
            {
				int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("UserInfo_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
				cmd.SetParameterValue("@RecordCount", tempRecord);
                List<UserInfo_Entity> pageList = cmd.ExecuteEntityList<UserInfo_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
				return pageList;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<UserInfo_Entity>(0);

        }

        public UserInfo_Entity UserInfo_View(System.Int32 UserID)
        {
            UserInfo_Entity c = default(UserInfo_Entity);
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("UserInfo_View");
                cmd.SetParameterValue("@UserID", UserID);
                c = cmd.ExecuteEntity<UserInfo_Entity>();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public UserInfo_Entity UserInfo_Add(UserInfo_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("UserInfo_Add");
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserName", entity.UserName);
                cmd.SetParameterValue("@Password", entity.Password);
                cmd.SetParameterValue("@FirstName", entity.FirstName);
                cmd.SetParameterValue("@LastName", entity.LastName);
                cmd.SetParameterValue("@Email", entity.Email);
                cmd.SetParameterValue("@Gender", entity.Gender);
                cmd.SetParameterValue("@Department", entity.Department);
                cmd.SetParameterValue("@JobTitle", entity.JobTitle);
                cmd.SetParameterValue("@PhoneNum", entity.PhoneNum);
                cmd.SetParameterValue("@FaxNum", entity.FaxNum);
                cmd.SetParameterValue("@Mobile", entity.Mobile);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool UserInfo_Update(UserInfo_Entity entity)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("UserInfo_Update");
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserName", entity.UserName);
                cmd.SetParameterValue("@Password", entity.Password);
                cmd.SetParameterValue("@FirstName", entity.FirstName);
                cmd.SetParameterValue("@LastName", entity.LastName);
                cmd.SetParameterValue("@Email", entity.Email);
                cmd.SetParameterValue("@Gender", entity.Gender);
                cmd.SetParameterValue("@Department", entity.Department);
                cmd.SetParameterValue("@JobTitle", entity.JobTitle);
                cmd.SetParameterValue("@PhoneNum", entity.PhoneNum);
                cmd.SetParameterValue("@FaxNum", entity.FaxNum);
                cmd.SetParameterValue("@Mobile", entity.Mobile);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool UserInfo_Delete(System.Int32 UserID)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("UserInfo_Delete");
                cmd.SetParameterValue("@UserID", UserID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }
		
	}
}
